
xtset ID

regress CandidateRecognition w5_newsexposure_mean knowledge_stable intefficacy w5_polinterest_eu turnoutintention_w5 euintegration PTV SeveralDomParties i.candidatename OwnCandidate female age education 
estat vif 

*** ====== ANALYSES IN MANUSCRIPT ===================
*** Figure 1 (descriptives only; Figure done in Excel) 
tab CandidateRecognition country if Eickhout==1, col
tab CandidateRecognition country if Keller==1, col
tab CandidateRecognition country if Timmermans==1, col
tab CandidateRecognition country if Verhofstadt==1, col
tab CandidateRecognition country if Vestager==1, col
tab CandidateRecognition country if Weber==1, col
tab CandidateRecognition country if Zahradil==1, col


*** Table 1 - Model 1
xtmelogit CandidateRecognition w5_newsexposure_mean knowledge_stable intefficacy w5_polinterest_eu turnoutintention_w5 euintegration female age education PTV SeveralDomParties i.candidatename OwnCandidate || country: , variance


*** Table 1 - Model 2
xtmelogit CandidateRecognition w5_newsexposure_mean knowledge_stable intefficacy w5_polinterest_eu turnoutintention_w5 euintegration female age education SeveralDomParties i.candidatename OwnCandidate || country: , variance


*** Table 1 - Model 3
xtmelogit CandidateRecognition w5_newsexposure_mean knowledge_stable intefficacy w5_polinterest_eu turnoutintention_w5 euintegration female age education SeveralDomParties i.candidatename OwnCandidate || country: w5_newsexposure_mean, variance


*** Figure 2
predict u*, reffects
bysort country: generate groups=(_n==1) 
list country u2 u1 if groups
gen intercept = _b[_cons] + u2
gen slope = _b[w5_newsexposure_mean] + u1
gen yhat= intercept + (slope*w5_newsexposure_mean)

twoway connected yhat w5_newsexposure_mean, connect(L) by(country)


*** ====== ANALYSES IN APPENDIX ===========
*** Appendix B 
*** Table A4

tab PTV country if Weber==1
tab PTV country if Timmermans==1
tab PTV country if Verhofstadt==1
tab PTV country if Vestager==1
tab PTV country if Eickhout==1
tab PTV country if Keller==1
tab PTV country if Zahradil==1

*** Table A5
sum w5_newsexposure_mean knowledge_stable intefficacy w5_polinterest_eu turnoutintention_w5 euintegration PTV SeveralDomParties OwnCandidate female age education if CandidateRecognition!=. 


*** Appendix C
drop u1 u2 groups intercept slope yhat

*** Table A9 - Model 1
xtmelogit CandidateRecognition w5_newsexposure_mean knowledge_stable intefficacy w5_polinterest_eu turnoutintention_w5 euintegration female age education PTV SeveralDomParties i.candidatename OwnCandidate || country: w5_newsexposure_mean, variance


*** Figure A1

predict u*, reffects
bysort country: generate groups=(_n==1) 
list country u2 u1 if groups
gen intercept = _b[_cons] + u2
gen slope = _b[w5_newsexposure_mean] + u1
gen yhat= intercept + (slope*w5_newsexposure_mean)

twoway connected yhat w5_newsexposure_mean, connect(L) by(country)


*** Table A9 - Model 2
xtmelogit CandidateRecognition c.w5_newsexposure_mean##OwnCandidate knowledge_stable intefficacy w5_polinterest_eu turnoutintention_w5 euintegration female age education PTV SeveralDomParties i.candidatename || country: , variance


*** Table A9 - Model 3
xtmelogit CandidateRecognition c.w5_newsexposure_mean##OwnCandidate knowledge_stable intefficacy w5_polinterest_eu turnoutintention_w5 euintegration female age education SeveralDomParties i.candidatename || country: , variance


*** Table A10
mean n_cand_rec, over(country) 


*** Table A11
mean n_foreign_can_rec_mean, over(country) 


*** Table A12
* generating alternative OwnCandidate variable
tab country
tab country, nolabel

gen OwnCandidate2=0
replace OwnCandidate2=1 if country==1
replace OwnCandidate2=1 if country==2
replace OwnCandidate2=1 if country==4
replace OwnCandidate2=1 if country==7

tab OwnCandidate2

* comparing distributions of the DV in stacked and non-stcaked data

sum n_cand_rec
sum n_cand_rec if Weber==1
sum n_cand_rec if Vestager==1

* fitting negative binomial regression model
nbreg n_cand_rec w5_newsexposure_mean knowledge_stable intefficacy w5_polinterest_eu turnoutintention_w5 euintegration female age education OwnCandidate2 i.country, cluster(ID) nolog
nbreg n_cand_rec c.w5_newsexposure_mean##country knowledge_stable intefficacy w5_polinterest_eu turnoutintention_w5 euintegration female age education OwnCandidate2, cluster(ID) nolog
* leads to multicollinearity between OwnCandidate2 and country - omit OwnCandidate2

*** Table A12 - model 1

nbreg n_cand_rec w5_newsexposure_mean knowledge_stable intefficacy w5_polinterest_eu turnoutintention_w5 euintegration female age education i.country, cluster(ID) nolog

*** Table A12 - model 2

nbreg n_cand_rec c.w5_newsexposure_mean##country knowledge_stable intefficacy w5_polinterest_eu turnoutintention_w5 euintegration female age education, cluster(ID) nolog

*** Figure A2

margins, at(w5_newsexposure_mean=(1(1)7) country=(1(1)10))
marginsplot, recast(line) noci yline(0)




